package reflect;

import java.lang.reflect.Method;
import java.util.ArrayList;

/**
 * 反射修改List add 方法
 * 只执行一遍
 * 后续list add 还是正常
 */
public class GenericIgnore {
    public static void main(String[] args) throws Exception {
        ArrayList<Integer> list = new ArrayList<>();
        list.add(2);
        list.add(4);
        list.add(1);
        Class<? extends ArrayList> aClass = list.getClass();
        Method add = aClass.getMethod("add", Object.class);
        add.invoke(list,"sassasasa");
        System.out.println(list);

    }
}
